﻿/****************************************************************************
Copyright (c) 2014-2016 Beijing TianRuiDiAn Network Technology Co.,Ltd.
Copyright (c) 2014-2016 ShenZhen Redbird Network Polytron Technologies Inc.
 
http://www.hotniao.com

All of the content of the software, including code, pictures, 
resources, are original. For unauthorized users, the company 
reserves the right to pursue its legal liability.

Create by: caojianlin

****************************************************************************/
using UnityEngine;
using UnityEditor;
using System.Collections;

public class HEScriptKeyReplace : UnityEditor.AssetModificationProcessor {
    public static void OnWillCreateAsset(string path)
{
        path = path.Replace(".meta", "");
        int index = path.LastIndexOf(".");
        string file = path.Substring(index);
        if (file != ".cs") return;
        string fileExtension = file;

        index = Application.dataPath.LastIndexOf("Assets");
        path = Application.dataPath.Substring(0, index) + path;
        file = System.IO.File.ReadAllText(path);
        
        file = file.Replace("#CREATIONDATE#", System.DateTime.Now.ToString("yyyy-MM-dd"));
        file = file.Replace("#AUTHOR#", "caojianlin");
        System.IO.File.WriteAllText(path, file, System.Text.Encoding.UTF8);
        AssetDatabase.Refresh();
    }

}
